package com.wtu.junit;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.wtu.bean.Manage;
import com.wtu.mapper.ManageMapper;
import com.wtu.utils.SqlSessionFactoryUtils;

public class Test_Util_Manage {

	private SqlSession sqlSession=null;
	private ManageMapper manageMapper=null;
	
	@Before
	public  void setUpBefore() throws Exception {
		sqlSession=SqlSessionFactoryUtils.openSession();
		manageMapper=sqlSession.getMapper(ManageMapper.class);
	}

	@After
	public  void tearDownAfter() throws Exception {
		sqlSession.close();
	}
	
	@Test
	public void test_findBySnoAndPassword(){
		System.out.println(manageMapper.findByNoAndPassword("201702041114", "123"));
	}
	
	@Test
	public void test_findById(){
		System.out.println(manageMapper.findById("201702041114"));
	}
	
	@Test
	public void test_updateById(){
		Manage manage=new Manage();
		manage.setM_no("201702072319");
		manage.setName("zhangxiaoyan");
		manage.setSex("m");
		manage.setPassword("123");
		manageMapper.updateById(manage);
		sqlSession.commit();
	}
	
	@Test
	public void test_insertInto(){
		Manage manage=new Manage();
		manage.setM_no("201702072319");
		manage.setName("zhangxiaoyan");
		manage.setSex("w");
		manage.setPassword("123");
		manageMapper.insertInto(manage);
		sqlSession.commit();
	}
	
	@Test
	public void test_selectAll(){
		List<Manage> list=manageMapper.selectAll();
		for (Manage manage : list) {
			System.out.println(manage);
		}
	}
	@Test
	public void test_findByString(){
		List<Manage> list=manageMapper.findByString("lile");
		for (Manage manage : list) {
			System.out.println(manage);
		}
	}
}
